#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
    int maxArea(vector<int>& height) {
        int left = 0, right = height.size() - 1, max = 0, v = 0;
        while (left < right)
        {
            v = (height[left] > height[right] ? height[right] : height[left]) * (right - left);
            if (v > max) max = v;
            height[left] > height[right] ? right-- : left++;
        }
        return max;
    }
};
int main()
{
    vector<int> v({ 1,8,6,2,5,4,8,3,7 });
    cout << Solution().maxArea(v) << endl;
	return 0;
}
/*
题目链接:https://leetcode.cn/problems/container-with-most-water/
*/